/**
 * Project Name:九色鹿
 * File Name:KuaiDiAutoConfiguration.java
 * Package Name:com.fxp.project.express.configuration
 * Date:2021年09月14日 15:09
 * Copyright (c) 2021, Jason.Wang All Rights Reserved.
 */
package com.fxp.project.express.configuration;

import com.fxp.project.express.config.KuaiDiProperties;
import com.fxp.project.express.provider.KuaiDiProvider;
import com.fxp.project.express.service.impl.QueryTrackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * ClassName:KuaiDiAutoConfiguration<br/>
 * Function: 快递100的配置<br/>
 * Date:2021年09月14日 15:09<br/>
 *
 * @author Jason.Wang
 * @version 1.0.0.0
 * @see
 * @since JDK 8
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "express.kuaidi", name = "customer")
@EnableConfigurationProperties({KuaiDiProperties.class})
@Import({KuaiDiProvider.class})
public class KuaiDiAutoConfiguration {
    private final KuaiDiProvider kuaiDiProvider;
    @Autowired
    private KuaiDiProperties properties;

    public KuaiDiAutoConfiguration(KuaiDiProvider kuaiDiProvider) {
        this.kuaiDiProvider = kuaiDiProvider;
    }

    @Bean(name = "queryTrackService")
    @ConditionalOnMissingBean(QueryTrackService.class)
    QueryTrackService autoNumServiceImpl() {
        QueryTrackService.initInstance(kuaiDiProvider.init(properties));
        return QueryTrackService.getInstance();
    }
}